#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n,r;
    vector<int> a;
    int temp;
    cin>>n>>r;
    for(int i = 0; i<n; i++)
    {
        cin>>temp;
        a.push_back(temp);
    }
    if((r+r)<n)
       sort(a.begin()+r,a.end()-r);
    for(int i = 0; i<n-1; i++)
        cout<<a[i]<<" ";
    cout<<a[n-1];
}